package cn.com.b2office.service.impl;

import java.util.Date;
import java.util.List;

import cn.com.b2office.dao.ItemCollectionDao;
import cn.com.b2office.domain.ItemCollection;
import cn.com.b2office.service.CollectionService;

public class CollectionServiceImpl implements CollectionService {

	private ItemCollectionDao itemCollectionDao = null;

	public void setItemCollectionDao(ItemCollectionDao itemCollectionDao) {
		this.itemCollectionDao = itemCollectionDao;
	}

	public void addCollection(String itemId, String memberId) {
		ItemCollection coll = new ItemCollection();
		coll.setItemId(itemId);
		coll.setMemberId(memberId);
		coll.setModifytime(new Date());
		itemCollectionDao.add(coll);

	}

	public List<ItemCollection> find(String memberId, int firstResult,
			int maxResults) {
		return itemCollectionDao.listCollection(memberId, firstResult,
				maxResults);
	}

	public List<ItemCollection> find(String memberId, String categoryId,
			int firstResult, int maxResults) {
		return itemCollectionDao.listCollection(memberId, categoryId,
				firstResult, maxResults);
	}

	public void removeCollection(int collectionId) {
		itemCollectionDao.remove(collectionId);

	}

	public int getTotalCollectionSize(String memberId) {
		return itemCollectionDao.getTotalCollectionSize(memberId);
	}

	public int getTotalCollectionSize(String memberId, String categoryId) {
		return itemCollectionDao.getTotalCollectionSize(memberId, categoryId);
	}

	public List<ItemCollection> findAll(String memberId) {
		return itemCollectionDao.listAllCollection(memberId);
	}

}
